import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MyDrawer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: buildListView(),
    );
  }

  ListView buildListView() {
    return ListView(
      children: [
        UserAccountsDrawerHeader(
          accountName: Text("Laze Ng"),
          accountEmail: Text("Laze_Ng@gmail.com"),
        ),
        ListTile(
          title: Text("Message"),
          subtitle: Text("send a message"),
          trailing: Icon(Icons.message, color: Colors.blue),
          onTap: () {
            _onTapAction(1);
          },
        ),
        ListTile(
          title: Text("Call"),
          subtitle: Text("call phone"),
          trailing: Icon(Icons.phone, color: Colors.blue),
          onTap: () {
            _onTapAction(2);
          },
        ),
        ListTile(
          title: Text("Contacts"),
          subtitle: Text("my contacts"),
          trailing: Icon(Icons.contacts, color: Colors.blue),
          onTap: () {
            _onTapAction(3);
          },
        )
      ],
    );
  }

  void _onTapAction(int i) {
    switch (i) {
      case 1:
        debugPrint("click message");
        break;
      case 2:
        debugPrint("click call");
        break;
      case 3:
        debugPrint("click contacts");
        break;
      default:
        debugPrint("click not found");
        break;
    }
  }
}
